var Dog = require("./dog");
var dog1 = new Dog("taidi", 4);
var dog2 = new Dog("zangao", 8);

dog1.on("bark",function(){
    dog1.bark();
});


var setIntervalId1 = setInterval(() => {
    dog1.emit("bark");
    dog1.energy -= 1;
    if(dog1.energy < 0){
        clearInterval(setIntervalId1);
    }
},1000);

dog2.on("bark",function(){
    dog2.bark();
});

var setIntervalId2 = setInterval(() => {
    dog2.emit("bark");
    dog2.energy -= 1;
    if(dog2.energy < 0){
        clearInterval(setIntervalId2);
    }
},1000);
